<template>
  <div class="son">
    <button @click="isShow = true">点我弹个窗</button>

    <!-- 可以直接写元素，也可以是类名 -->
    <Teleport to="body">
      <div class="mark" v-if="isShow">
        <div class="dialog">
          <h3>我是一个弹窗</h3>
          <h4>一些内容</h4>
          <h4>一些内容</h4>
          <h4>一些内容</h4>
          <button @click="isShow = false">关闭弹窗</button>
        </div>
      </div>
    </Teleport>
  </div>
</template>

<script>
import { ref } from 'vue'


export default {
  name: 'Dialog',

  setup() {
    let isShow = ref(false)
    return {
      isShow
    }
  }
}
</script>

<style>
.mark {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}
.dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  text-align: center;
  background-color: green;
}
</style>